all <- read.csv("../02-descriptive_data/merged_filtered_imputedMedian_likertNumber.csv")
rownames(all) <- all$Resp.ID
Seven, is the number of factors that would be present according to the study design. Using very relaxed cutoff of 0.2 to get rid of not important variables in each factor.
# items to be used for the FA
usable_items <- likert_variables1[!(likert_variables1 %in% c("necessity1","educated1","reconnect.comm1", "speakersmelb.comm1", "comecloser.comm1"))]
usable_data <- all[,usable_items]
sum(is.na(usable_data))
[1] 0
# Cronbach's alpha using consistent items across contexts
psych::alpha(usable_data,use="pairwise.complete.obs")
Reliability analysis
Call: psych::alpha(x = usable_data, use = "pairwise.complete.obs")
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd
0.84 0.86 0.9 0.17 5.9 0.013 4 0.33
lower alpha upper 95% confidence boundaries
0.81 0.84 0.86
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se
converse.id1 0.83 0.85 0.89 0.16 5.5 0.014
dream.id1 0.83 0.85 0.90 0.17 5.6 0.013
usewell.id1 0.83 0.85 0.90 0.17 5.7 0.013
whenever.id1 0.83 0.85 0.89 0.16 5.5 0.014
consider.ought1 0.84 0.86 0.90 0.18 6.0 0.012
people.ought1 0.84 0.86 0.90 0.17 5.9 0.013
expect.ought1 0.84 0.86 0.90 0.18 6.0 0.013
fail.ought1 0.84 0.86 0.90 0.18 6.0 0.013
enjoy.intr1 0.83 0.85 0.89 0.17 5.7 0.013
life.intr1 0.83 0.85 0.89 0.16 5.5 0.014
exciting.intr1 0.83 0.85 0.89 0.17 5.6 0.013
challenge.intr1 0.83 0.85 0.90 0.17 5.7 0.013
job.instru1 0.83 0.85 0.89 0.17 5.6 0.014
knowledge.instru1 0.83 0.85 0.90 0.17 5.8 0.013
career.instru1 0.83 0.85 0.89 0.17 5.6 0.014
money.instru1 0.83 0.85 0.90 0.17 5.8 0.013
time.integr1 0.83 0.85 0.89 0.17 5.6 0.013
becomelike.integr1 0.83 0.85 0.90 0.17 5.8 0.013
meeting.integr1 0.83 0.85 0.90 0.17 5.7 0.013
affinity.integr1 0.84 0.85 0.90 0.17 5.8 0.013
improve.prof1 0.83 0.85 0.90 0.17 5.7 0.013
speaking.prof1 0.83 0.85 0.89 0.17 5.6 0.013
reading.prof1 0.84 0.85 0.89 0.17 5.8 0.013
written.prof1 0.83 0.85 0.89 0.17 5.6 0.013
listening.prof1 0.83 0.85 0.89 0.17 5.6 0.013
citizen.post1 0.83 0.85 0.90 0.17 5.7 0.014
interact.post1 0.83 0.85 0.90 0.17 5.7 0.013
overseas.post1 0.83 0.85 0.89 0.17 5.6 0.014
globalaccess.post1 0.83 0.85 0.89 0.17 5.5 0.014
Item statistics
n raw.r std.r r.cor r.drop mean sd
converse.id1 323 0.59 0.59 0.58 0.53 4.3 0.76
dream.id1 323 0.49 0.51 0.49 0.44 4.5 0.65
usewell.id1 323 0.42 0.43 0.40 0.35 4.3 0.72
whenever.id1 323 0.57 0.57 0.56 0.51 4.3 0.82
consider.ought1 323 0.27 0.20 0.16 0.16 2.6 1.12
people.ought1 323 0.36 0.28 0.24 0.25 3.1 1.16
expect.ought1 323 0.29 0.21 0.18 0.20 1.9 0.92
fail.ought1 323 0.29 0.23 0.19 0.20 2.1 0.96
enjoy.intr1 323 0.43 0.46 0.44 0.38 4.5 0.64
life.intr1 323 0.62 0.60 0.59 0.55 3.3 1.04
exciting.intr1 323 0.50 0.54 0.52 0.45 4.6 0.56
challenge.intr1 323 0.41 0.42 0.39 0.33 4.2 0.79
job.instru1 323 0.50 0.49 0.47 0.43 3.8 0.83
knowledge.instru1 323 0.39 0.40 0.36 0.33 4.2 0.65
career.instru1 323 0.50 0.50 0.49 0.43 4.2 0.77
money.instru1 323 0.40 0.39 0.36 0.33 3.2 0.77
time.integr1 323 0.46 0.49 0.46 0.40 4.5 0.66
becomelike.integr1 323 0.43 0.40 0.36 0.34 3.1 0.95
meeting.integr1 323 0.42 0.45 0.43 0.37 4.6 0.57
affinity.integr1 323 0.39 0.37 0.34 0.31 3.6 0.87
improve.prof1 323 0.38 0.43 0.41 0.32 4.5 0.75
speaking.prof1 323 0.44 0.50 0.50 0.40 4.7 0.53
reading.prof1 323 0.34 0.39 0.37 0.28 4.5 0.62
written.prof1 323 0.46 0.51 0.50 0.41 4.6 0.58
listening.prof1 323 0.44 0.49 0.49 0.39 4.5 0.63
citizen.post1 323 0.50 0.48 0.45 0.42 3.8 0.89
interact.post1 323 0.44 0.47 0.44 0.38 4.4 0.62
overseas.post1 323 0.51 0.55 0.53 0.47 4.6 0.58
globalaccess.post1 323 0.53 0.56 0.54 0.48 4.3 0.67
Non missing response frequency for each item
1 2 3 4 5 miss
converse.id1 0.00 0.03 0.10 0.41 0.47 0
dream.id1 0.00 0.00 0.07 0.36 0.56 0
usewell.id1 0.00 0.02 0.11 0.46 0.42 0
whenever.id1 0.00 0.03 0.12 0.37 0.47 0
consider.ought1 0.14 0.40 0.21 0.19 0.06 0
people.ought1 0.09 0.27 0.25 0.28 0.11 0
expect.ought1 0.39 0.44 0.09 0.07 0.01 0
fail.ought1 0.27 0.46 0.16 0.10 0.01 0
enjoy.intr1 0.00 0.01 0.06 0.40 0.54 0
life.intr1 0.02 0.24 0.25 0.36 0.12 0
exciting.intr1 0.00 0.01 0.02 0.37 0.61 0
challenge.intr1 0.00 0.03 0.12 0.48 0.36 0
job.instru1 0.00 0.04 0.32 0.41 0.23 0
knowledge.instru1 0.00 0.01 0.09 0.59 0.32 0
career.instru1 0.00 0.00 0.20 0.41 0.39 0
money.instru1 0.01 0.12 0.55 0.26 0.06 0
time.integr1 0.00 0.01 0.07 0.29 0.63 0
becomelike.integr1 0.03 0.23 0.47 0.18 0.10 0
meeting.integr1 0.00 0.00 0.03 0.37 0.59 0
affinity.integr1 0.01 0.07 0.36 0.39 0.17 0
improve.prof1 0.01 0.02 0.03 0.34 0.59 0
speaking.prof1 0.00 0.01 0.00 0.28 0.71 0
reading.prof1 0.00 0.02 0.02 0.38 0.59 0
written.prof1 0.00 0.01 0.02 0.36 0.62 0
listening.prof1 0.00 0.01 0.04 0.38 0.57 0
citizen.post1 0.01 0.07 0.23 0.46 0.23 0
interact.post1 0.00 0.00 0.06 0.43 0.50 0
overseas.post1 0.00 0.01 0.02 0.34 0.63 0
globalaccess.post1 0.00 0.01 0.06 0.49 0.43 0
fact <- 7
loading_cutoff <- 0.2
fa_basic <- fa(usable_data,fact)
Loading required namespace: GPArotation
fa_basic
Factor Analysis using method = minres
Call: fa(r = usable_data, nfactors = fact)
Standardized loadings (pattern matrix) based upon correlation matrix
MR2 MR3 MR4 MR7 MR5 MR6 MR1 h2 u2
converse.id1 0.09 0.10 0.04 0.35 0.14 0.26 0.08 0.40 0.60
dream.id1 0.17 0.07 0.16 0.19 0.17 -0.04 0.38 0.39 0.61
usewell.id1 -0.02 0.03 0.18 0.13 0.17 0.06 0.30 0.28 0.72
whenever.id1 -0.03 0.12 0.18 0.11 0.28 0.21 0.25 0.44 0.56
consider.ought1 0.10 0.51 0.06 0.14 -0.09 -0.13 -0.18 0.38 0.62
people.ought1 -0.04 0.48 0.24 0.09 0.01 -0.14 0.08 0.31 0.69
expect.ought1 0.03 0.80 0.01 0.04 -0.03 -0.09 -0.06 0.68 0.32
fail.ought1 -0.02 0.73 -0.10 -0.12 -0.01 0.16 0.12 0.53 0.47
enjoy.intr1 0.02 -0.12 0.01 0.01 0.81 -0.06 0.01 0.66 0.34
life.intr1 -0.11 0.20 0.09 0.14 0.55 0.18 0.00 0.55 0.45
exciting.intr1 0.25 0.02 -0.02 0.16 0.33 0.07 0.14 0.35 0.65
challenge.intr1 0.21 0.00 -0.05 -0.03 0.45 0.07 -0.14 0.29 0.71
job.instru1 0.00 0.01 0.83 0.00 -0.03 0.01 -0.03 0.68 0.32
knowledge.instru1 0.12 0.13 -0.02 -0.02 0.15 0.33 -0.22 0.24 0.76
career.instru1 0.00 -0.06 0.65 -0.01 0.03 0.12 0.14 0.57 0.43
money.instru1 0.02 0.03 0.59 -0.08 0.08 0.02 -0.13 0.36 0.64
time.integr1 0.06 -0.05 -0.08 0.57 0.06 0.12 0.19 0.46 0.54
becomelike.integr1 0.01 0.05 0.03 0.49 0.12 0.04 -0.30 0.37 0.63
meeting.integr1 0.05 -0.11 -0.01 0.51 0.11 0.04 0.17 0.40 0.60
affinity.integr1 -0.09 0.04 0.01 0.74 -0.03 -0.04 -0.06 0.52 0.48
improve.prof1 0.70 -0.03 -0.07 0.08 -0.04 0.07 -0.06 0.51 0.49
speaking.prof1 0.80 -0.06 0.08 0.09 -0.10 0.00 0.01 0.65 0.35
reading.prof1 0.69 0.01 -0.03 -0.13 0.11 -0.04 0.01 0.51 0.49
written.prof1 0.76 0.05 0.08 -0.03 0.05 -0.06 0.09 0.61 0.39
listening.prof1 0.85 0.05 -0.06 -0.05 0.03 0.05 -0.05 0.76 0.24
citizen.post1 0.04 0.11 0.16 0.03 0.04 0.49 -0.28 0.42 0.58
interact.post1 -0.02 -0.12 0.16 0.05 0.10 0.40 0.13 0.36 0.64
overseas.post1 0.26 -0.02 0.10 0.12 -0.11 0.46 0.06 0.41 0.59
globalaccess.post1 0.00 -0.11 0.15 0.05 0.05 0.62 0.05 0.57 0.43
com
converse.id1 2.7
dream.id1 3.0
usewell.id1 3.0
whenever.id1 4.5
consider.ought1 1.8
people.ought1 1.8
expect.ought1 1.0
fail.ought1 1.3
enjoy.intr1 1.1
life.intr1 1.8
exciting.intr1 2.9
challenge.intr1 1.7
job.instru1 1.0
knowledge.instru1 3.0
career.instru1 1.2
money.instru1 1.2
time.integr1 1.4
becomelike.integr1 1.8
meeting.integr1 1.5
affinity.integr1 1.1
improve.prof1 1.1
speaking.prof1 1.1
reading.prof1 1.1
written.prof1 1.1
listening.prof1 1.0
citizen.post1 2.0
interact.post1 2.0
overseas.post1 2.0
globalaccess.post1 1.2
MR2 MR3 MR4 MR7 MR5 MR6 MR1
SS loadings 3.30 1.86 2.00 1.95 1.89 1.79 0.85
Proportion Var 0.11 0.06 0.07 0.07 0.07 0.06 0.03
Cumulative Var 0.11 0.18 0.25 0.31 0.38 0.44 0.47
Proportion Explained 0.24 0.14 0.15 0.14 0.14 0.13 0.06
Cumulative Proportion 0.24 0.38 0.53 0.67 0.81 0.94 1.00
With factor correlations of
MR2 MR3 MR4 MR7 MR5 MR6 MR1
MR2 1.00 0.08 0.10 0.08 0.20 0.24 0.04
MR3 0.08 1.00 0.07 0.08 -0.03 0.02 -0.15
MR4 0.10 0.07 1.00 0.26 0.27 0.42 0.14
MR7 0.08 0.08 0.26 1.00 0.33 0.28 0.12
MR5 0.20 -0.03 0.27 0.33 1.00 0.36 0.20
MR6 0.24 0.02 0.42 0.28 0.36 1.00 0.14
MR1 0.04 -0.15 0.14 0.12 0.20 0.14 1.00
Mean item complexity = 1.8
Test of the hypothesis that 7 factors are sufficient.
The degrees of freedom for the null model are 406 and the objective function was 10.52 with Chi Square of 3278.37
The degrees of freedom for the model are 224 and the objective function was 1.23
The root mean square of the residuals (RMSR) is 0.03
The df corrected root mean square of the residuals is 0.04
The harmonic number of observations is 323 with the empirical chi square 224.23 with prob < 0.48
The total number of observations was 323 with Likelihood Chi Square = 376.07 with prob < 8.2e-10
Tucker Lewis Index of factoring reliability = 0.902
RMSEA index = 0.049 and the 90 % confidence intervals are 0.038 0.054
BIC = -918.12
Fit based upon off diagonal values = 0.98
Measures of factor score adequacy
MR2 MR3 MR4 MR7
Correlation of (regression) scores with factors 0.95 0.90 0.90 0.88
Multiple R square of scores with factors 0.90 0.81 0.82 0.77
Minimum correlation of possible factor scores 0.80 0.62 0.63 0.53
MR5 MR6 MR1
Correlation of (regression) scores with factors 0.89 0.86 0.75
Multiple R square of scores with factors 0.79 0.74 0.57
Minimum correlation of possible factor scores 0.58 0.49 0.13
# plot loadings
loadings_basic <- fa_basic$loadings
class(loadings_basic)<-"matrix"
colnames(loadings_basic)<-paste("F",1:fact,sep="")
loadings_basic<-as.data.frame(loadings_basic)
loadings_basic<-round(loadings_basic,2)
loadings_basic$D <- rownames(loadings_basic)
a1 <- loadings_basic
a1 <- melt(a1,id.vars=c("D"))
a1$inv <- ifelse(a1$value < 0 ,"neg","pos")
a1$value[abs(a1$value) < loading_cutoff] <- 0
a1 <- a1[a1$value!=0,]
a1 <- a1 %>% separate(D,into = c("Variable","Item"),remove=FALSE,sep="[.]")
ggplot(a1)+geom_bar(aes(x=reorder(D, value) ,y=value,fill=Item),stat="identity")+facet_wrap(~variable,ncol = 2,scales = "free_y")+coord_flip() + geom_hline(yintercept = c(-0.3,0.3),linetype="dotted",colour="dark red")
# Table of the factors
loadings_basic$D <- NULL
loadings_basic[abs(loadings_basic) < loading_cutoff] <- 0
for(i in 1:ncol(loadings_basic)){loadings_basic[,i] <- as.character(loadings_basic[,i])}
loadings_basic[loadings_basic=="0"] <- ""
loading_fact_reduced <- loadings_basic
loading_fact_reduced
# predict values per samples
pred_basic <- as.data.frame(predict(fa_basic,usable_data))
names(pred_basic) <- paste("Factor",1:fact,sep = "")
factors <- names(pred_basic)
match_initial_data <- match(all$Resp.ID,rownames(pred_basic))
all_complete_basic <- cbind(all,scale(pred_basic[match_initial_data,]))
corrplot(cor(all_complete_basic[,usable_items],all_complete_basic[,factors],use = "pair"))
# Plot loadings by context
all_complete_basic <- melt(all_complete_basic,id.vars = "Context",measure.vars = factors)
library(ggplot2)
ggplot(all_complete_basic)+geom_boxplot(aes(x=Context,y=value,color=Context))+facet_wrap(~variable)+coord_flip()+guides(color=F)
# 7 * 12 rows removed
Using very relaxed cutoff of 0.2 to get rid of not important variables in each factor.
# items to be used for the FA
usable_items <- likert_variables1[!(likert_variables1 %in% c("necessity1","educated1","reconnect.comm1", "speakersmelb.comm1", "comecloser.comm1"))]
usable_data <- all[,usable_items]
# From a statisticak point of view
fap <- fa.parallel(usable_data)
Parallel analysis suggests that the number of factors = 6 and the number of components = 4
fact <- 6
loading_cutoff <- 0.2
fa_basic <- fa(usable_data,fact)
fa_basic
Factor Analysis using method = minres
Call: fa(r = usable_data, nfactors = fact)
Standardized loadings (pattern matrix) based upon correlation matrix
MR2 MR4 MR3 MR5 MR1 MR6 h2 u2 com
converse.id1 0.10 0.12 0.06 0.38 0.20 0.13 0.40 0.60 2.3
dream.id1 0.18 0.27 0.04 0.22 0.25 -0.27 0.37 0.63 4.7
usewell.id1 -0.01 0.29 -0.01 0.16 0.25 -0.15 0.27 0.73 3.2
whenever.id1 -0.01 0.31 0.06 0.14 0.39 -0.01 0.43 0.57 2.3
consider.ought1 0.08 -0.04 0.57 0.10 -0.13 0.05 0.37 0.63 1.3
people.ought1 -0.05 0.22 0.51 0.06 0.02 -0.12 0.31 0.69 1.6
expect.ought1 0.03 -0.03 0.83 0.01 -0.01 0.01 0.70 0.30 1.0
fail.ought1 0.01 0.01 0.62 -0.09 0.10 0.05 0.39 0.61 1.1
enjoy.intr1 0.02 -0.05 -0.12 0.01 0.73 -0.02 0.55 0.45 1.1
life.intr1 -0.11 0.10 0.18 0.13 0.61 0.15 0.56 0.44 1.5
exciting.intr1 0.25 0.02 -0.01 0.18 0.38 -0.03 0.35 0.65 2.3
challenge.intr1 0.21 -0.10 0.00 -0.05 0.43 0.14 0.26 0.74 1.9
job.instru1 -0.01 0.78 0.06 -0.01 -0.07 0.05 0.58 0.42 1.0
knowledge.instru1 0.13 -0.02 0.11 -0.02 0.17 0.38 0.24 0.76 1.9
career.instru1 0.00 0.76 -0.06 -0.01 0.04 -0.02 0.59 0.41 1.0
money.instru1 0.01 0.52 0.07 -0.10 0.02 0.11 0.30 0.70 1.2
time.integr1 0.07 0.00 -0.08 0.63 0.10 -0.03 0.47 0.53 1.1
becomelike.integr1 -0.01 -0.08 0.11 0.43 0.04 0.22 0.27 0.73 1.7
meeting.integr1 0.05 0.03 -0.12 0.56 0.13 -0.08 0.41 0.59 1.3
affinity.integr1 -0.11 -0.05 0.09 0.72 -0.07 0.03 0.49 0.51 1.1
improve.prof1 0.70 -0.08 -0.03 0.09 -0.06 0.09 0.51 0.49 1.1
speaking.prof1 0.80 0.08 -0.04 0.10 -0.12 -0.01 0.65 0.35 1.1
reading.prof1 0.70 -0.04 0.01 -0.14 0.11 -0.04 0.51 0.49 1.1
written.prof1 0.76 0.09 0.05 -0.03 0.05 -0.10 0.61 0.39 1.1
listening.prof1 0.86 -0.07 0.05 -0.05 0.03 0.07 0.76 0.24 1.0
citizen.post1 0.05 0.21 0.09 0.03 0.05 0.52 0.43 0.57 1.4
interact.post1 0.01 0.32 -0.19 0.10 0.19 0.17 0.34 0.66 3.2
overseas.post1 0.29 0.27 -0.08 0.17 -0.02 0.25 0.36 0.64 3.8
globalaccess.post1 0.05 0.36 -0.19 0.11 0.16 0.34 0.50 0.50 3.2
MR2 MR4 MR3 MR5 MR1 MR6
SS loadings 3.35 2.47 1.88 2.11 2.15 1.03
Proportion Var 0.12 0.09 0.06 0.07 0.07 0.04
Cumulative Var 0.12 0.20 0.27 0.34 0.41 0.45
Proportion Explained 0.26 0.19 0.14 0.16 0.17 0.08
Cumulative Proportion 0.26 0.45 0.59 0.76 0.92 1.00
With factor correlations of
MR2 MR4 MR3 MR5 MR1 MR6
MR2 1.00 0.13 0.05 0.11 0.22 0.16
MR4 0.13 1.00 0.00 0.33 0.37 0.24
MR3 0.05 0.00 1.00 0.03 -0.05 0.11
MR5 0.11 0.33 0.03 1.00 0.39 0.16
MR1 0.22 0.37 -0.05 0.39 1.00 0.16
MR6 0.16 0.24 0.11 0.16 0.16 1.00
Mean item complexity = 1.8
Test of the hypothesis that 6 factors are sufficient.
The degrees of freedom for the null model are 406 and the objective function was 10.52 with Chi Square of 3278.37
The degrees of freedom for the model are 247 and the objective function was 1.46
The root mean square of the residuals (RMSR) is 0.03
The df corrected root mean square of the residuals is 0.04
The harmonic number of observations is 323 with the empirical chi square 293.67 with prob < 0.022
The total number of observations was 323 with Likelihood Chi Square = 448.4 with prob < 7.6e-14
Tucker Lewis Index of factoring reliability = 0.883
RMSEA index = 0.053 and the 90 % confidence intervals are 0.043 0.058
BIC = -978.68
Fit based upon off diagonal values = 0.98
Measures of factor score adequacy
MR2 MR4 MR3 MR5
Correlation of (regression) scores with factors 0.95 0.91 0.90 0.88
Multiple R square of scores with factors 0.90 0.82 0.81 0.78
Minimum correlation of possible factor scores 0.80 0.65 0.63 0.55
MR1 MR6
Correlation of (regression) scores with factors 0.89 0.78
Multiple R square of scores with factors 0.79 0.61
Minimum correlation of possible factor scores 0.57 0.22
# plot loadings
loadings_basic <- fa_basic$loadings
class(loadings_basic)<-"matrix"
colnames(loadings_basic)<-paste("F",1:fact,sep="")
loadings_basic<-as.data.frame(loadings_basic)
loadings_basic<-round(loadings_basic,2)
loadings_basic$D <- rownames(loadings_basic)
a1 <- loadings_basic
a1 <- melt(a1,id.vars=c("D"))
a1$inv <- ifelse(a1$value < 0 ,"neg","pos")
a1$value[abs(a1$value) < loading_cutoff] <- 0
a1 <- a1[a1$value!=0,]
a1 <- a1 %>% separate(D,into = c("Variable","Item"),remove=FALSE,sep="[.]")
ggplot(a1)+geom_bar(aes(x=reorder(D, value) ,y=value,fill=Item),stat="identity")+facet_wrap(~variable,ncol = 2,scales = "free_y")+coord_flip() + geom_hline(yintercept = c(-0.3,0.3),linetype="dotted",colour="dark red")
# Table of the factors
loadings_basic$D <- NULL
loadings_basic[abs(loadings_basic) < loading_cutoff] <- 0
for(i in 1:ncol(loadings_basic)){loadings_basic[,i] <- as.character(loadings_basic[,i])}
loadings_basic[loadings_basic=="0"] <- ""
loading_fact_reduced <- loadings_basic
loading_fact_reduced
# predict values per samples
pred_basic <- as.data.frame(predict(fa_basic,usable_data))
names(pred_basic) <- paste("Factor",1:fact,sep = "")
factors <- names(pred_basic)
match_initial_data <- match(all$Resp.ID,rownames(pred_basic))
all_complete_basic <- cbind(all,scale(pred_basic[match_initial_data,]))
corrplot(cor(all_complete_basic[,usable_items],all_complete_basic[,factors],use = "pair"))
# Plot loadings by context
all_complete_basic <- melt(all_complete_basic,id.vars = "Context",measure.vars = factors)
library(ggplot2)
ggplot(all_complete_basic)+geom_boxplot(aes(x=Context,y=value,color=Context))+facet_wrap(~variable)+coord_flip()+guides(color=F)
# 7 * 12 rows removed
# error bar
sum_stat <- all_complete_basic %>% group_by(Context,variable) %>%
summarise(meanFac = mean(value,na.rm=TRUE),
stdFac = sd(value,na.rm=TRUE),
nObs = length(Context[!is.na(value)])) %>%
mutate(seMean = stdFac/sqrt(nObs),
CI95 = 1.96*seMean)
ggplot(sum_stat,aes(x=Context,y=meanFac,colour=Context)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2) + facet_wrap(~variable,scales="free_y") + geom_point() +theme(axis.text.x = element_text(angle = 45, hjust = 1))+ ggtitle("Mean +- 95% CI")
ggplot(sum_stat,aes(x=variable,y=meanFac,colour=variable)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2) + facet_wrap(~Context,scales="free_y") +
geom_point() + ggtitle("Mean +- 95% CI")
kable(sum_stat)
| Context | variable | meanFac | stdFac | nObs | seMean | CI95 |
|---|---|---|---|---|---|---|
| English in Germany | Factor1 | -0.7673653 | 1.2968739 | 70 | 0.1550061 | 0.3038119 |
| English in Germany | Factor2 | 0.2464654 | 0.8811501 | 70 | 0.1053176 | 0.2064224 |
| English in Germany | Factor3 | -0.4025772 | 0.6874385 | 70 | 0.0821646 | 0.1610427 |
| English in Germany | Factor4 | 0.3070734 | 0.9509279 | 70 | 0.1136576 | 0.2227689 |
| English in Germany | Factor5 | 0.0672303 | 0.8805028 | 70 | 0.1052402 | 0.2062708 |
| English in Germany | Factor6 | -0.3916784 | 1.0244232 | 70 | 0.1224420 | 0.2399863 |
| English in Italy | Factor1 | 0.1674403 | 0.7825545 | 91 | 0.0820340 | 0.1607866 |
| English in Italy | Factor2 | 0.5194919 | 0.7674261 | 91 | 0.0804481 | 0.1576783 |
| English in Italy | Factor3 | 0.0054434 | 0.9238201 | 91 | 0.0968427 | 0.1898116 |
| English in Italy | Factor4 | 0.0311704 | 0.9431596 | 91 | 0.0988700 | 0.1937852 |
| English in Italy | Factor5 | 0.4084333 | 0.8766512 | 91 | 0.0918980 | 0.1801201 |
| English in Italy | Factor6 | 0.3768171 | 0.8018947 | 91 | 0.0840614 | 0.1647604 |
| German in Australia | Factor1 | 0.2302922 | 0.7943686 | 88 | 0.0846800 | 0.1659728 |
| German in Australia | Factor2 | -0.2004232 | 1.0176085 | 88 | 0.1084774 | 0.2126158 |
| German in Australia | Factor3 | 0.0300804 | 1.1010277 | 88 | 0.1173699 | 0.2300451 |
| German in Australia | Factor4 | -0.2897234 | 1.1273569 | 88 | 0.1201766 | 0.2355462 |
| German in Australia | Factor5 | -0.3245639 | 1.0203688 | 88 | 0.1087717 | 0.2131925 |
| German in Australia | Factor6 | -0.0289222 | 1.0127781 | 88 | 0.1079625 | 0.2116065 |
| Italian in Australia | Factor1 | 0.2461188 | 0.7676304 | 74 | 0.0892352 | 0.1749010 |
| Italian in Australia | Factor2 | -0.6336365 | 0.9310097 | 74 | 0.1082277 | 0.2121263 |
| Italian in Australia | Factor3 | 0.3383511 | 1.0930484 | 74 | 0.1270643 | 0.2490460 |
| Italian in Australia | Factor4 | 0.0157300 | 0.8670613 | 74 | 0.1007938 | 0.1975559 |
| Italian in Australia | Factor5 | -0.1798909 | 1.0572445 | 74 | 0.1229022 | 0.2408883 |
| Italian in Australia | Factor6 | -0.0584826 | 1.0369273 | 74 | 0.1205404 | 0.2362591 |
# items to be used for the FA
usable_items <- likert_variables1[!(likert_variables1 %in% c("necessity1","educated1","reconnect.comm1", "speakersmelb.comm1", "comecloser.comm1"))]
usable_data <- all[,c(usable_items,"Context")]
dat_onlyItems <- usable_data[,usable_items]
# get residuals after regressing for context
get_residuals <- function(item,pred = dat$Context){
mod <- lm(item ~ pred)
return(mod$residuals)
}
applygetRes <- apply(as.matrix(dat_onlyItems),2,get_residuals,
pred=usable_data$Context)
# Factanal
# From a statisticak point of view
fap <- fa.parallel(applygetRes)
Parallel analysis suggests that the number of factors = 6 and the number of components = 6
fact <- 6
loading_cutoff <- 0.2
fa_basic <- fa(applygetRes,fact)
fa_basic
Factor Analysis using method = minres
Call: fa(r = applygetRes, nfactors = fact)
Standardized loadings (pattern matrix) based upon correlation matrix
MR2 MR1 MR3 MR4 MR5 MR6 h2 u2 com
converse.id1 0.06 0.45 0.04 0.12 0.14 0.09 0.39 0.61 1.5
dream.id1 0.16 0.29 0.04 0.23 0.21 -0.28 0.37 0.63 4.4
usewell.id1 0.08 0.15 0.04 0.21 0.25 -0.10 0.22 0.78 3.4
whenever.id1 0.01 0.23 0.09 0.21 0.34 -0.02 0.36 0.64 2.7
consider.ought1 0.08 0.02 0.56 0.04 -0.10 0.10 0.36 0.64 1.2
people.ought1 0.01 0.03 0.53 0.17 -0.01 -0.09 0.32 0.68 1.3
expect.ought1 0.00 0.02 0.82 -0.02 -0.01 0.00 0.67 0.33 1.0
fail.ought1 0.00 -0.03 0.62 -0.04 0.06 0.01 0.39 0.61 1.0
enjoy.intr1 0.02 0.00 -0.11 -0.02 0.75 -0.02 0.57 0.43 1.0
life.intr1 -0.09 0.18 0.18 0.07 0.55 0.12 0.51 0.49 1.7
exciting.intr1 0.17 0.21 -0.02 0.08 0.39 -0.07 0.37 0.63 2.1
challenge.intr1 0.17 -0.08 -0.01 -0.05 0.46 0.15 0.28 0.72 1.6
job.instru1 0.00 -0.04 0.06 0.78 -0.05 0.05 0.60 0.40 1.0
knowledge.instru1 0.03 -0.02 0.06 0.06 0.21 0.38 0.25 0.75 1.7
career.instru1 -0.01 0.03 -0.07 0.72 0.03 -0.04 0.53 0.47 1.0
money.instru1 -0.01 -0.14 0.07 0.54 0.07 0.12 0.33 0.67 1.3
time.integr1 0.04 0.64 -0.05 -0.01 0.09 -0.02 0.47 0.53 1.1
becomelike.integr1 0.00 0.38 0.11 -0.06 0.05 0.25 0.26 0.74 2.1
meeting.integr1 0.07 0.55 -0.09 -0.01 0.10 -0.06 0.38 0.62 1.2
affinity.integr1 -0.09 0.67 0.11 -0.05 -0.06 0.07 0.44 0.56 1.1
improve.prof1 0.64 0.14 -0.06 -0.04 -0.07 0.06 0.44 0.56 1.2
speaking.prof1 0.73 0.13 -0.07 0.12 -0.13 -0.04 0.60 0.40 1.2
reading.prof1 0.69 -0.13 0.01 -0.08 0.10 -0.01 0.48 0.52 1.1
written.prof1 0.78 -0.05 0.08 0.04 0.05 -0.05 0.62 0.38 1.1
listening.prof1 0.83 -0.04 0.03 -0.06 0.04 0.06 0.69 0.31 1.0
citizen.post1 0.05 0.06 0.07 0.13 0.00 0.54 0.40 0.60 1.2
interact.post1 0.09 0.21 -0.17 0.14 0.12 0.19 0.25 0.75 4.9
overseas.post1 0.29 0.20 -0.06 0.18 -0.03 0.27 0.35 0.65 3.6
globalaccess.post1 0.05 0.15 -0.19 0.29 0.15 0.35 0.46 0.54 3.5
MR2 MR1 MR3 MR4 MR5 MR6
SS loadings 3.08 2.28 1.87 2.07 1.99 1.07
Proportion Var 0.11 0.08 0.06 0.07 0.07 0.04
Cumulative Var 0.11 0.19 0.25 0.32 0.39 0.43
Proportion Explained 0.25 0.18 0.15 0.17 0.16 0.09
Cumulative Proportion 0.25 0.43 0.59 0.75 0.91 1.00
With factor correlations of
MR2 MR1 MR3 MR4 MR5 MR6
MR2 1.00 0.20 -0.04 0.23 0.27 0.11
MR1 0.20 1.00 0.05 0.35 0.40 0.20
MR3 -0.04 0.05 1.00 0.08 -0.04 0.12
MR4 0.23 0.35 0.08 1.00 0.30 0.27
MR5 0.27 0.40 -0.04 0.30 1.00 0.16
MR6 0.11 0.20 0.12 0.27 0.16 1.00
Mean item complexity = 1.8
Test of the hypothesis that 6 factors are sufficient.
The degrees of freedom for the null model are 406 and the objective function was 9.64 with Chi Square of 3002.9
The degrees of freedom for the model are 247 and the objective function was 1.41
The root mean square of the residuals (RMSR) is 0.03
The df corrected root mean square of the residuals is 0.04
The harmonic number of observations is 323 with the empirical chi square 304.9 with prob < 0.007
The total number of observations was 323 with Likelihood Chi Square = 433.55 with prob < 2.2e-12
Tucker Lewis Index of factoring reliability = 0.88
RMSEA index = 0.051 and the 90 % confidence intervals are 0.041 0.056
BIC = -993.53
Fit based upon off diagonal values = 0.98
Measures of factor score adequacy
MR2 MR1 MR3 MR4
Correlation of (regression) scores with factors 0.94 0.88 0.9 0.89
Multiple R square of scores with factors 0.88 0.78 0.8 0.80
Minimum correlation of possible factor scores 0.76 0.56 0.6 0.60
MR5 MR6
Correlation of (regression) scores with factors 0.88 0.78
Multiple R square of scores with factors 0.77 0.61
Minimum correlation of possible factor scores 0.54 0.22
# plot loadings
loadings_basic <- fa_basic$loadings
class(loadings_basic)<-"matrix"
colnames(loadings_basic)<-paste("F",1:fact,sep="")
loadings_basic<-as.data.frame(loadings_basic)
loadings_basic<-round(loadings_basic,2)
loadings_basic$D <- rownames(loadings_basic)
a1 <- loadings_basic
a1 <- melt(a1,id.vars=c("D"))
a1$inv <- ifelse(a1$value < 0 ,"neg","pos")
a1$value[abs(a1$value) < loading_cutoff] <- 0
a1 <- a1[a1$value!=0,]
a1 <- a1 %>% separate(D,into = c("Variable","Item"),remove=FALSE,sep="[.]")
ggplot(a1)+geom_bar(aes(x=reorder(D, value) ,y=value,fill=Item),stat="identity")+facet_wrap(~variable,ncol = 2,scales = "free_y")+coord_flip() + geom_hline(yintercept = c(-0.3,0.3),linetype="dotted",colour="dark red")
# Table of the factors
loadings_basic$D <- NULL
loadings_basic[abs(loadings_basic) < loading_cutoff] <- 0
for(i in 1:ncol(loadings_basic)){loadings_basic[,i] <- as.character(loadings_basic[,i])}
loadings_basic[loadings_basic=="0"] <- ""
loading_fact_reduced <- loadings_basic
loading_fact_reduced
# predict values per samples
pred_basic <- as.data.frame(predict(fa_basic,dat_onlyItems))
names(pred_basic) <- paste("Factor",1:fact,sep = "")
factors <- names(pred_basic)
match_initial_data <- match(all$Resp.ID,rownames(pred_basic))
all_complete_basic <- cbind(all,scale(pred_basic[match_initial_data,]))
corrplot(cor(all_complete_basic[,usable_items],all_complete_basic[,factors],use = "pair"))
# Plot loadings by context
all_complete_melt <- melt(all_complete_basic,id.vars = "Context",measure.vars = factors)
library(ggplot2)
ggplot(all_complete_melt)+geom_boxplot(aes(x=Context,y=value,color=Context))+facet_wrap(~variable)+coord_flip()+guides(color=F)
# error bar
sum_stat <- all_complete_melt %>% group_by(Context,variable) %>%
summarise(meanFac = mean(value,na.rm=TRUE),
stdFac = sd(value,na.rm=TRUE),
nObs = length(Context[!is.na(value)])) %>%
mutate(seMean = stdFac/sqrt(nObs),
CI95 = 1.96*seMean)
ggplot(sum_stat,aes(x=Context,y=meanFac,colour=Context)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2) + facet_wrap(~variable,scales="free_y") + geom_point() +theme(axis.text.x = element_text(angle = 45, hjust = 1))+ ggtitle("Mean +- 95% CI")
ggplot(sum_stat,aes(x=variable,y=meanFac,colour=variable)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2) + facet_wrap(~Context,scales="free_y") +
geom_point() + ggtitle("Mean +- 95% CI")
kable(sum_stat)
| Context | variable | meanFac | stdFac | nObs | seMean | CI95 |
|---|---|---|---|---|---|---|
| English in Germany | Factor1 | -0.7262823 | 1.3027239 | 70 | 0.1557053 | 0.3051824 |
| English in Germany | Factor2 | 0.2482873 | 0.9717385 | 70 | 0.1161450 | 0.2276441 |
| English in Germany | Factor3 | -0.3577921 | 0.6873827 | 70 | 0.0821579 | 0.1610296 |
| English in Germany | Factor4 | 0.1984720 | 0.9209535 | 70 | 0.1100750 | 0.2157470 |
| English in Germany | Factor5 | 0.0623044 | 0.8805362 | 70 | 0.1052442 | 0.2062786 |
| English in Germany | Factor6 | -0.2942834 | 1.0170296 | 70 | 0.1215583 | 0.2382543 |
| English in Italy | Factor1 | 0.1843902 | 0.7928113 | 91 | 0.0831092 | 0.1628940 |
| English in Italy | Factor2 | 0.1305766 | 0.9120258 | 91 | 0.0956063 | 0.1873883 |
| English in Italy | Factor3 | 0.0131736 | 0.9281411 | 91 | 0.0972956 | 0.1906994 |
| English in Italy | Factor4 | 0.4605985 | 0.8027893 | 91 | 0.0841552 | 0.1649442 |
| English in Italy | Factor5 | 0.3597625 | 0.8859079 | 91 | 0.0928684 | 0.1820220 |
| English in Italy | Factor6 | 0.3618400 | 0.8155681 | 91 | 0.0854948 | 0.1675697 |
| German in Australia | Factor1 | 0.2071940 | 0.8075060 | 88 | 0.0860804 | 0.1687176 |
| German in Australia | Factor2 | -0.3001195 | 1.1310092 | 88 | 0.1205660 | 0.2363093 |
| German in Australia | Factor3 | 0.0073308 | 1.1099903 | 88 | 0.1183254 | 0.2319177 |
| German in Australia | Factor4 | -0.1437635 | 1.0280115 | 88 | 0.1095864 | 0.2147893 |
| German in Australia | Factor5 | -0.2915304 | 1.0361113 | 88 | 0.1104498 | 0.2164817 |
| German in Australia | Factor6 | -0.0633571 | 1.0120855 | 88 | 0.1078887 | 0.2114618 |
| Italian in Australia | Factor1 | 0.2138808 | 0.7800659 | 74 | 0.0906808 | 0.1777344 |
| Italian in Australia | Factor2 | -0.0385415 | 0.8820267 | 74 | 0.1025335 | 0.2009657 |
| Italian in Australia | Factor3 | 0.3135343 | 1.1005654 | 74 | 0.1279381 | 0.2507587 |
| Italian in Australia | Factor4 | -0.5831934 | 0.9398504 | 74 | 0.1092554 | 0.2141406 |
| Italian in Australia | Factor5 | -0.1546625 | 1.0673902 | 74 | 0.1240816 | 0.2431999 |
| Italian in Australia | Factor6 | -0.0912455 | 1.0643970 | 74 | 0.1237336 | 0.2425179 |
demographics_var <- c("Age","Gender","L1","speak.other.L2","study.other.L2","origins","year.studyL2","other5.other.ways","degree","roleL2.degree","study.year","prof","L2.VCE","uni1.year","Context")
dat_fac_demo <- all_complete_basic[,c(demographics_var,factors)]
table(dat_fac_demo$Age)
18-25 26-30 31-35
318 4 1
table(dat_fac_demo$L1) # to be changed
Afrikaans Albanian Cantonese
1 1 2
Chinese Dutch English
4 1 147
English and Dutch German German and English
2 63 2
I Indonesian Italian
1 1 87
Japanese Mandarin Persian (Farsi)
1 2 1
Romanian Russian Sindhi
1 2 1
Spanish Turkish Ukrainian
1 1 1
table(dat_fac_demo$speak.other.L2) # to be changed
Afrikaans
1
Arabic
1
Azeri, Turkish and English
1
Chinese
1
Chinese (Cantonese)
1
Dutch (and German)
1
English
5
English\nJapanese
1
English, Javanese
1
English, Mandarin
1
French
10
French and learning Spanish
1
French, Greek.
1
French, not fluent, but have a fair amount of knowledge
1
French.
1
German
1
German (proficient/advanced level)
1
German and Japanese
1
German, French
1
German.
1
Greek
2
Hindi
1
Indonesian
1
Indonesian and French (not fluent in either, but did VCE both of them)
1
Irish
1
Italian
5
Japanese
1
Macedonian
1
No
141
Only German
1
Polish
1
Russian
1
Serbian
1
Some Italian
1
Spanish
2
Swedish
1
Telugu
1
Urdu, English
1
Yes
124
table(dat_fac_demo$study.other.L2) # to be changed
Ancient Greek
1
Arab
1
Arabian
1
Arabic
2
Arabo
1
Chinese
7
CHINESE
1
Chinese (Mandarin)
1
Chinese mandarin
1
Chinese.
1
Dutch
2
Finnish
1
Francese
1
French
19
French (5 semesters) until 07/2016
1
french and spanish
2
French and Spanish
1
French, Greek.
1
French,Spanish
1
French.
2
German
9
I also study French at university level.
1
I am also learning Spanish at University, although only at beginner level, unlike German.
1
I study Russian, I plan to learn Spanish and hopefully also Portuguese
1
I'm studying German. Since I've never studied it before, I a beginner.
1
Italian
5
japanese
1
Japanese
13
Japanese (very beginner)
1
Japanese but I'm not going to continue learning it
1
Japanese.
1
Latin
1
Latin, Ancient Egyptian, Ancient Greek.
1
Latin, doesn't really count.
1
Netherlands
1
No
179
Nonna da Pescara
1
Polish
2
Portoghese
1
Portugese
1
Portuguese
2
Russian
15
Russian.
1
russo
1
Russo
2
siehe oben
1
Spagnolo
2
Spagnolo e un po' di giapponese
1
Spanish
16
Spanish (1)
1
Spanish.
2
tedesco
1
Tedesco
5
Will start my French diploma soon
1
table(dat_fac_demo$origins)
No Yes
254 69
table(dat_fac_demo$year.studyL2) # to be changed
0 years 1- 3 years
33 9
1-3 years 4-6 years
7 53
BILINGUAL First year of primary school
4 73
FIRST.YEAR.SECONDARY FOURTH.YEAR.PRIMARY
10 5
Kindergarten Less than a year
29 18
LOWER.SECONDARY more than 6 years
4 41
PERSONAL SECOND.YEAR.PRIMARY
2 2
SECOND.YEAR.SECONDARY THIRD.YEAR.PRIMARY
2 28
table(dat_fac_demo$other5.other.ways) # to be changed
COURSE COURSE; MEDIA
5 1
EXCHANGE FRIENDS
6 4
HERITAGE L2.RESOURCES
4 19
L2.RESOURCES, MEDIA L2.RESOURCES; MEDIA
1 1
LIVING.L2 M.PRIVATE.LESSONS
7 2
NO.OTHER.WAYS ONLINE.COURSE
1 4
PERSONAL PERSONAL.HERITAGE
3 2
QC SELF.STUDY
1 7
STUDY.HOLIDAY TRAVEL.FRIENDS.L2.RESOURCES
5 1
TRAVELLING WORK.L2
8 2
table(dat_fac_demo$degree) # to be changed
BA in Anglistik BA in Nordamerikastudien
39 4
HUM HUM.SCI
97 5
LA Lingue e letterature straniere
27 78
Lingue, mercati e culture dell'Asia QC
13 4
SCI
56
table(dat_fac_demo$roleL2.degree) # not usable
First or second language
91
table(dat_fac_demo$study.year)
1st semester 1st year
70 253
table(dat_fac_demo$prof)
Advanced Elementary Intermediate
65 63 68
Upper-intermediate
127
table(dat_fac_demo$L2.VCE)
No Yes
47 90
table(dat_fac_demo$uni1.year) # not usable
1st year
162
demo_melt <- melt(all_complete_basic,id.vars = c("Age","Gender","origins","study.year","prof","L2.VCE","Context"),measure.vars = factors)
# age
ageStat <- demo_melt %>% group_by(Context,Age,variable) %>%
summarise(meanFac = mean(value,na.rm=TRUE),
stdFac = sd(value,na.rm=TRUE),
nObs = length(Age[!is.na(value)])) %>%
mutate(seMean = stdFac/sqrt(nObs),
CI95 = 1.96*seMean)
ageStat$Demo <- "Age"
colnames(ageStat)[2] <- "levels"
ageStat <- data.frame(ageStat)
# Gender
GenderStat <- demo_melt %>% group_by(Context,Gender,variable) %>%
summarise(meanFac = mean(value,na.rm=TRUE),
stdFac = sd(value,na.rm=TRUE),
nObs = length(Gender[!is.na(value)])) %>%
mutate(seMean = stdFac/sqrt(nObs),
CI95 = 1.96*seMean)
GenderStat$Demo <- "Gender"
colnames(GenderStat)[2] <- "levels"
GenderStat <- data.frame(GenderStat)
# origins
originsStat <- demo_melt %>% group_by(Context,origins,variable) %>%
summarise(meanFac = mean(value,na.rm=TRUE),
stdFac = sd(value,na.rm=TRUE),
nObs = length(origins[!is.na(value)])) %>%
mutate(seMean = stdFac/sqrt(nObs),
CI95 = 1.96*seMean)
originsStat$Demo <- "origins"
colnames(originsStat)[2] <- "levels"
originsStat <- data.frame(originsStat)
# study.year
study.yearStat <- demo_melt %>% group_by(Context,study.year,variable) %>%
summarise(meanFac = mean(value,na.rm=TRUE),
stdFac = sd(value,na.rm=TRUE),
nObs = length(study.year[!is.na(value)])) %>%
mutate(seMean = stdFac/sqrt(nObs),
CI95 = 1.96*seMean)
study.yearStat$Demo <- "Study Year"
colnames(study.yearStat)[2] <- "levels"
study.yearStat <- data.frame(study.yearStat)
# prof
profStat <- demo_melt %>% group_by(Context,prof,variable) %>%
summarise(meanFac = mean(value,na.rm=TRUE),
stdFac = sd(value,na.rm=TRUE),
nObs = length(prof[!is.na(value)])) %>%
mutate(seMean = stdFac/sqrt(nObs),
CI95 = 1.96*seMean)
profStat$Demo <- "Proficiency"
colnames(profStat)[2] <- "levels"
profStat$levels <- as.character(profStat$levels)
profStat <- data.frame(profStat)
# L2.VCE
L2.VCEStat <- demo_melt %>% group_by(Context,L2.VCE,variable) %>%
summarise(meanFac = mean(value,na.rm=TRUE),
stdFac = sd(value,na.rm=TRUE),
nObs = length(L2.VCE[!is.na(value)])) %>%
mutate(seMean = stdFac/sqrt(nObs),
CI95 = 1.96*seMean)
L2.VCEStat$Demo <- "L2.VCE"
colnames(L2.VCEStat)[2] <- "levels"
L2.VCEStat$levels <- as.character(L2.VCEStat$levels)
L2.VCEStat <- data.frame(L2.VCEStat)
##################
# Combine stats
##################
combine_stat <- rbind(data.frame(L2.VCEStat),data.frame(profStat),study.yearStat,originsStat,ageStat,GenderStat)
kable(ageStat)
kable(GenderStat)
kable(originsStat)
kable(study.yearStat)
kable(profStat)
kable(L2.VCEStat)
pos <- position_dodge(width=0.4)
ggplot(subset(combine_stat,variable %in% c("Factor1")),aes(x=levels,y=meanFac,colour=Context,group=Context)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2,position=pos) + facet_wrap(~Demo ,scales="free") +
geom_point(position=pos) + ggtitle("Factor1: Mean +- 95% CI") + theme_bw()
pos <- position_dodge(width=0.4)
ggplot(subset(combine_stat,variable %in% c("Factor2")),aes(x=levels,y=meanFac,colour=Context,group=Context)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2,position=pos) + facet_wrap(~Demo ,scales="free") +
geom_point(position=pos) + ggtitle("Factor2: Mean +- 95% CI") + theme_bw()
pos <- position_dodge(width=0.4)
ggplot(subset(combine_stat,variable %in% c("Factor3")),aes(x=levels,y=meanFac,colour=Context,group=Context)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2,position=pos) + facet_wrap(~Demo ,scales="free") +
geom_point(position=pos) + ggtitle("Factor3: Mean +- 95% CI") + theme_bw()
pos <- position_dodge(width=0.4)
ggplot(subset(combine_stat,variable %in% c("Factor4")),aes(x=levels,y=meanFac,colour=Context,group=Context)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2,position=pos) + facet_wrap(~Demo ,scales="free") +
geom_point(position=pos) + ggtitle("Factor4: Mean +- 95% CI") + theme_bw()
pos <- position_dodge(width=0.4)
ggplot(subset(combine_stat,variable %in% c("Factor5")),aes(x=levels,y=meanFac,colour=Context,group=Context)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2,position=pos) + facet_wrap(~Demo ,scales="free") +
geom_point(position=pos) + ggtitle("Factor5: Mean +- 95% CI") + theme_bw()
pos <- position_dodge(width=0.4)
ggplot(subset(combine_stat,variable %in% c("Factor6")),aes(x=levels,y=meanFac,colour=Context,group=Context)) +
geom_errorbar(aes(ymin=meanFac-CI95, ymax=meanFac+CI95),width=0.2,position=pos) + facet_wrap(~Demo ,scales="free") +
geom_point(position=pos) + ggtitle("Factor6: Mean +- 95% CI") + theme_bw()
We could probably reduce the number of classes.
# L2.VCE
degreeStat <- degree_melt %>% group_by(Context,degree,variable) %>%
summarise(meanFac = mean(value,na.rm=TRUE),
stdFac = sd(value,na.rm=TRUE),
nObs = length(L2.VCE[!is.na(value)])) %>%
mutate(seMean = stdFac/sqrt(nObs),
CI95 = 1.96*seMean)
Error in summarise_impl(.data, dots) :
Evaluation error: object 'L2.VCE' not found.